<?php
class getMatchRankList extends ActionHandler 
{
	function handleRequest($jsonData)
	{
		$params = $jsonData['params'];
		$matchIndex = $params['matchIndex'];
		$return = array();
		for ($i = 0; $i < 4; $i++)
		{
			$sqltemp = array("dayofyear(buildDate) = dayofyear(CURRENT_TIMESTAMP) and type = 0", "weekofyear(buildDate) = weekofyear(CURRENT_TIMESTAMP) and type = 1", "month(buildDate) = month(CURRENT_TIMESTAMP) and type = 2", "type = 3");
			$sql = "select matchIndex, builderName as name, height, population as score, buildDate from ".$this->tables['match_profile']." where matchIndex = ".$matchIndex." and ".$sqltemp[$i]." order by population desc limit 0,50";
			$result = $this->db->query($sql);
			$rankingList = array();
			$ranking = 0;
			while ($arr = $this->db->fetchArray($result))
			{
				$arr["ranking"] = $ranking;
				$rankingList[$ranking] = $arr;
				$ranking++;
			}
			$return[$i] = $rankingList;
		}
		return $return;
	}
}
?>
